home *** CD-ROM | disk | FTP | other *** search
- /* header file for project qndxr -- by ^z -- 870820-0913-...
- */
-
- /* tell what compiler we're using ... Lightspeed C by Think, if the
- * following line is #defined ... essentially, when LIGHTSPEED is here,
- * assume that we have only 16-bit int variables and that Macintosh
- * toolbox traps are available ... when LIGHTSPEED is not #defined,
- * assume that ints can hold more like 32 bits without error, so more
- * can be done using standard I/O routines from <stdio>
- */
- #define LIGHTSPEED
-
- /* preprocessor 'function' to turn on/off debug printing of detailed info
- * during program runs ... when debugging, use a statement:
- * #define DEBUG(fmt, arg) printf (fmt, arg)
- * ... and when not debugging, just use: #define DEBUG(fmt, arg)
- * to effectively remove those print commands....
- */
- /* #define DEBUG(fmt, arg) printf (fmt, arg) */
- #define DEBUG(fmt, arg)
-
- /* sort on KEY_LENGTH characters ... make it 28 rather arbitrarily as an
- * experiment ... want it long enough to avoid truncation of legitimate
- * words, but short enough to save some space in the *.k files ... an
- * alternative value is 12, for compatibility with the older ndxr.c program
- * and brwsr.c, if they haven't been revised to allow for longer keys....
- */
- #define KEY_LENGTH 28
-
- /* define a structure for the index_keys file
- */
- typedef struct
- {
- char kkey[KEY_LENGTH];
- long ccount;
- } KEY_REC;
-
- /* define a structure for my simpleminded I/O buffers ...
- */
- typedef struct
- {
- char *zbufbase;
- char *zbufp;
- long zbufcounter;
- long zbufsize;
- FILE *zbuffilep;
- int zbufitemsize;
- } ZBUF;
-
- /* choose this size to be the default memory size used for total buffer
- * space ... for convenience on the Mac Plus, I have picked 512 kB, which
- * leaves me a bit of space to spare ....
- */
- #define DEFAULT_MEMSIZ 524288
-
- /* merge this many files at each stage of the merging operation for index
- * building ... 2 means a binary merge, etc. ... one needs to have at least
- * 5 + 2 * NMERGE I/O buffers around: for each of NMERGE files, there is
- * a *.k keys file and a *.p pointers file; plus there must be a single
- * output *.k and a single output *.p file; plus there is the need for stdin,
- * stdout, and stderr to be open as well. Thus, I have found that a 4-way
- * merge (NMERGE = 4) works pretty nicely....
- */
- #define NMERGE 4
-
- #ifndef TRUE
- #define TRUE 1
- #endif
-
- #ifndef FALSE
- #define FALSE 0
- #endif
-
- /* CMASK makes sure that a returned character isn't sign-extended
- */
- #ifndef CMASK
- #define CMASK 0xFF
- #endif
-
- /* put the prototypes for my functions here... assume that if LIGHTSPEED
- * is #define'd, then we want to use prototypes....
- */
- #ifdef LIGHTSPEED
-
- /* in qndxr unix main.c */
- void punt(void);
- void openfile(FILE *file, char *mode);
- void main(void);
-
- /* in qndxr.c */
- void _main(int argc, char *argv[]);
-
- /* in bufio.c */
- void create_zbuffer (int n, long bufsize, FILE *buffile, int bufitemsize);
- void free_zbuffer (int n);
- char *next_input_item (int n);
- void load_zbuffer (int n);
- char *next_output_item (int n);
- void flush_zbuffer (int n);
-
- /* in build_indices.c */
- int build_indices (void);
-
- /* in doc_buf.c */
- char *make_buf (long bufsiz);
- long load_doc_buffer (char *doc, long doc_bufsiz, char **ptr);
- int filtered_getc (void);
-
- /* in merge_files.c */
- void nway_merge_kpfiles (FILE *ink[], FILE *inp[], FILE *outk, FILE *outp,
- int n);
- void copy_ptr_recs (int inzbuf, long count, int outzbuf);
- void copy_key_rec (char *kkey, long ccount, int outzbuf);
- int merge_not_finished (KEY_REC *kr[], int n);
- int smallest_key (KEY_REC *kr[], int n);
-
- /* in merge_indices.c */
- int merge_indices (char *doc_filename);
-
- /* in file_utils.c */
- void write_sorted_files (char *doc, char **ptr, long nwords,
- int pass_number, long offset);
- int is_new_word (char *w0, char *w1);
- void write_new_key (char *p, char *kp);
-
- /* in merge_utils.c */
- FILE *open_inkfile (int generation_number, int file_number);
- FILE *open_inpfile (int generation_number, int file_number);
- void fix_oddball_file_name (int generation_number, int file_number);
- void fix_final_file_names (int generation_number, char *doc_filename);
- FILE *open_outkfile (int generation_number, int file_number);
- FILE *open_outpfile (int generation_number, int file_number);
- void remove_used_infiles (int generation_number, int file_number, int n);
- void close_infiles (FILE *ink[], FILE *inp[], int n);
-
- /* in misc_utils.c */
- long set_params (int argc, char *argv[]);
- long set_zbufsiz (long zb);
- void set_parser_options (char *str);
- void check_interrupt (void);
- long file_size (FILE *fp);
-
- /* in open_files.c */
- FILE *open_docfile (int argc, char *argv[]);
- FILE *open_kfile (int pass_number);
- FILE *open_pfile (int pass_number);
-
- /* in zqsort.c */
- void zqsort (char **first, char **last);
- int compare_ptrs (char **p1, char **p2);
- int zstrcmp (char *s1, char *s2);
-
- #endif
-